<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class House_model extends CI_Model
{
	/**
	 * 查看
	 */
	public function chak($limit,$offset)
	{
		$arr = $this->db->select('house.*,type.type_name,floor.floor_sn')->from('house')
				->join('type','house.house_type=type.type_id')
				->join('floor','house.floor_sn=floor.floor_id')
				->order_by('house_id','descr')
			    ->limit($limit,$offset)
			    ->get()
				->result_array();
		return $arr;
	}
	/**
	 * [add description] 房屋添加
	 * @param [type] $data [description]
	 */
	public function add($data)
	{
		$res=$this->db->insert('house',$data);
		return $res;
	}
		/**
	 * 修改查看
	 */
	public function updas($id)
	{
		$arr = $this->db->where(array('house_id'=>$id))->get('house')->result_array();
		foreach ($arr as $v) {
			$arr = $v;
		}
			return $arr;
	}
	/**
	 * 修改之数据处理
	 */
	public function update($id,$data)
	{
		$arr= $this->db->update('house',$data,array('house_id'=>$id));
		return $arr;
	}
			/**
	 * 删除
	 */
	public function del($id)
	{
		$bool = $this->db->delete('house',array('house_id'=>$id));
		return $bool;
	}

	public function faceData()
	{
		$arr = $this->db->order_by('house_id','desc')->limit(3)->get('house')->result_array();
		return $arr;
	}






}